﻿/*
 编辑摘要信息和关键词
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using XMK.Tadong.Model;
using XMK.Tadong.Biz;
using System.Data;
using HU8.Web.FileExplorer;

namespace XMK.Tadong.Web.WebFileExplorer.DataSubmit
{
    public partial class EditInfo : FileExplorerPage
    {
        #region 变量

        //类型，关键词:GJC 摘要信息:ZYXX
        public string Type = string.Empty;
        //文件ID
        public string File_ID = string.Empty;
        //操作类型,个人空间：individual，课题组：group，项目库：project
        public string spacetype = string.Empty;

        #endregion 变量

        #region 事件处理程序

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitData();
            }
        }
        
         //提交按钮点击事件
        protected void btnSunmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(this.Request.QueryString["Type"]))
                {
                    Type = this.Request.QueryString["Type"];
                }
                if (!string.IsNullOrEmpty(this.Request.QueryString["File_ID"]))
                {
                    File_ID = this.Request.QueryString["File_ID"];
                }
                if (!string.IsNullOrEmpty(this.Request.QueryString["spacetype"]))
                {
                    spacetype = this.Request.QueryString["spacetype"];
                }
                if (Type.Equals("ZYXX"))
                {
                    if (spacetype.Equals("individual"))
                    {
                        TB_PERSON_FILEInfo model = new TB_PERSON_FILEInfo();
                        TB_PERSON_FILEBiz bll = new TB_PERSON_FILEBiz();
                        model.FILE_ABST = txtXX.Text.Trim();
                        model.FILE_ID = Convert.ToDecimal(File_ID);
                        bool flag = bll.UpDateInfo(model, "ZYXX");
                        if (flag)
                        {
                            lblErr.Text = "修改成功";
                            //ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>parent.window.document.getElementById('button1').click();</script>");
                            ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "myscript", "<script>window.parent.document.location.reload();</script>");

                        }
                    }
                    else if (spacetype.Equals("group"))
                    {
                        TB_TEAM_FILEInfo model = new TB_TEAM_FILEInfo();
                        TB_TEAM_FILEBiz bll = new TB_TEAM_FILEBiz();
                        model.FILE_ABST = txtXX.Text.Trim();
                        model.FILE_ID = int.Parse(File_ID);
                        bool flag = bll.UpDateInfo(model, "ZYXX");
                        if (flag)
                        {
                            lblErr.Text = lang.Get("SPACE_Modified_successfully");
                            //ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>window.parent.document.location.reload();</script>");
                            ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "myscript", "<script>window.parent.document.location.reload();</script>");
                        }
                    }
                    else if (spacetype.Equals("project"))
                    {
                        TB_XMK_FILEInfo model = new TB_XMK_FILEInfo();
                        Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
                        model.FILE_ABST = txtXX.Text.Trim();
                        model.FILE_ID = int.Parse(File_ID);
                        bool flag = bll.UpDateInfo(model, "ZYXX");
                        if (flag)
                        {
                            lblErr.Text = lang.Get("SPACE_Modified_successfully");
                            //ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>parent.window.document.getElementById('button1').click();</script>");
                            ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "myscript", "<script>window.parent.document.location.reload();</script>");
                        }
                    }
                }
                else if (Type.Equals("GJC"))
                {
                    if (spacetype.Equals("individual"))
                    {
                        TB_PERSON_FILEInfo model = new TB_PERSON_FILEInfo();
                        TB_PERSON_FILEBiz bll = new TB_PERSON_FILEBiz();
                        model.KEYW = txtXX.Text.Trim();
                        model.FILE_ID = Convert.ToDecimal(File_ID);
                        bool flag = bll.UpDateInfo(model, "GJC");
                        if (flag)
                        {
                            lblErr.Text = lang.Get("SPACE_Modified_successfully");
                            //ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>parent.window.document.getElementById('button1').click();</script>");
                            ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "myscript", "<script>window.parent.document.location.reload();</script>");
                        }
                    }
                    else if (spacetype.Equals("group"))
                    {
                        TB_TEAM_FILEInfo model = new TB_TEAM_FILEInfo();
                        TB_TEAM_FILEBiz bll = new TB_TEAM_FILEBiz();
                        model.KEYW = txtXX.Text.Trim();
                        model.FILE_ID = int.Parse(File_ID);
                        bool flag = bll.UpDateInfo(model, "GJC");
                        if (flag)
                        {
                            lblErr.Text = lang.Get("SPACE_Modified_successfully");
                            //ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>parent.window.document.getElementById('button1').click();</script>");
                            ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "myscript", "<script>window.parent.document.location.reload();</script>");
                        }
                    }
                    else if (spacetype.Equals("project"))
                    {
                        TB_XMK_FILEInfo model = new TB_XMK_FILEInfo();
                        Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
                        model.KEYW = txtXX.Text.Trim();
                        model.FILE_ID = int.Parse(File_ID);
                        bool flag = bll.UpDateInfo(model, "GJC");
                        if (flag)
                        {
                            lblErr.Text = lang.Get("SPACE_Modified_successfully");
                            //ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>parent.window.document.getElementById('button1').click();</script>");
                            ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "myscript", "<script>window.parent.document.location.reload();</script>");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lblErr.Text = ex.Message;
            }
        }

        #endregion 事件处理程序

        #region 函数集

        //页面初始化函数
        public void InitData()
        {
            if (!string.IsNullOrEmpty(this.Request.QueryString["Type"]))
            {
                Type = this.Request.QueryString["Type"];
            }
            if (!string.IsNullOrEmpty(this.Request.QueryString["File_ID"]))
            {
                File_ID = this.Request.QueryString["File_ID"];
            }
            if (!string.IsNullOrEmpty(this.Request.QueryString["spacetype"]))
            {
                spacetype = this.Request.QueryString["spacetype"];
            }
            if (Type.Equals("ZYXX"))
            {
                if (spacetype.Equals("individual"))
                {
                    TB_PERSON_FILEInfo model = new TB_PERSON_FILEInfo();
                    TB_PERSON_FILEBiz bll = new TB_PERSON_FILEBiz();
                    model = bll.GetFileInfoById(File_ID);
                    txtXX.Text = model.FILE_ABST.ToString();

                }
                else if (spacetype.Equals("group"))
                {
                    TB_TEAM_FILEBiz bll = new TB_TEAM_FILEBiz();
                    DataTable dt = bll.GetModel(File_ID);
                    if (dt.Rows.Count > 0)
                    {
                        txtXX.Text = dt.Rows[0]["FILE_ABST"].ToString();
                    }
                }
                else if (spacetype.Equals("project"))
                {
                    Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
                    DataTable dt = bll.GetModel(File_ID);
                    if (dt.Rows.Count > 0)
                    {
                        txtXX.Text = dt.Rows[0]["FILE_ABST"].ToString();
                    }
                }
            }
            else if (Type.Equals("GJC"))
            {
                if (spacetype.Equals("individual"))
                {
                    TB_PERSON_FILEInfo model = new TB_PERSON_FILEInfo();
                    TB_PERSON_FILEBiz bll = new TB_PERSON_FILEBiz();
                    model = bll.GetFileInfoById(File_ID);
                    txtXX.Text = model.KEYW.ToString();

                }
                else if (spacetype.Equals("group"))
                {
                    TB_TEAM_FILEBiz bll = new TB_TEAM_FILEBiz();
                    DataTable dt = bll.GetModel(File_ID);
                    if (dt.Rows.Count > 0)
                    {
                        txtXX.Text = dt.Rows[0]["KEYW"].ToString();
                    }
                }
                else if (spacetype.Equals("project"))
                {
                    Tb_Xmk_FileBiz bll = new Tb_Xmk_FileBiz();
                    DataTable dt = bll.GetModel(File_ID);
                    if (dt.Rows.Count > 0)
                    {
                        txtXX.Text = dt.Rows[0]["KEYW"].ToString();
                    }
                }
            }
        }

        #endregion 函数集
    }
}